<?php



/**
 * ForumsCategory
 */
class ForumsCategory
{
    /**
     * @var integer $id
     */
    private $id;

    /**
     * @var string $title
     */
    private $title;

    /**
     * @var integer $pos
     */
    private $pos;

    /**
     * @var Forum
     */
    private $forums;

    public function __construct()
    {
        $this->forums = new \Doctrine\Common\Collections\ArrayCollection();
    }
    
    /**
     * Get id
     *
     * @return integer $id
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set title
     *
     * @param string $title
     */
    public function setTitle($title)
    {
        $this->title = $title;
    }

    /**
     * Get title
     *
     * @return string $title
     */
    public function getTitle()
    {
        return $this->title;
    }

    /**
     * Set pos
     *
     * @param integer $pos
     */
    public function setPos($pos)
    {
        $this->pos = $pos;
    }

    /**
     * Get pos
     *
     * @return integer $pos
     */
    public function getPos()
    {
        return $this->pos;
    }

    /**
     * Add forums
     *
     * @param Forum $forums
     */
    public function addForums(\Forum $forums)
    {
        $this->forums[] = $forums;
    }

    /**
     * Get forums
     *
     * @return Doctrine\Common\Collections\Collection $forums
     */
    public function getForums()
    {
        return $this->forums;
    }

    /***
     * Retourne true si possède des forums à afficher
     */
    public function hasForumCredential($_session) {
        if ( $this->forums->isEmpty() ) return false; // Pas de forum = pas visible
        
        foreach ($this->forums AS $forum) {
            if ( $forum->hasCredential($_session) ) {
                return true; // Un seul forum visible = catégorie visible
            }
        }

        return false; // Aucun forum à afficher = catégorie pas visible
    }
}